\section{music::music\_\-system Class Reference}
\label{classmusic_1_1music__system}\index{music::music_system@{music::music\_\-system}}
This class provides a facade for the whole music-system.  


{\tt \#include $<$music\_\-system.h$>$}

\subsection*{Public Member Functions}
\begin{CompactItemize}
\item 
\bf{music\_\-system} ()\label{classmusic_1_1music__system_683856fd3b2e40f10dd3415cc28e41bc}

\item 
\bf{$\sim$music\_\-system} ()\label{classmusic_1_1music__system_b8f19e3dc163c824e7f7d8e2647bd4bb}

\item 
void \bf{add\_\-music} (boost::shared\_\-ptr$<$ \bf{model::dom} $>$ node, boost::shared\_\-ptr$<$ \bf{network::i\_\-socket} $>$ sock)
\begin{CompactList}\small\item\em add\_\-music adds new music-data to the \doxyref{music\_\-system}{p.}{classmusic_1_1music__system}. \item\end{CompactList}\item 
void \bf{remove\_\-music} (boost::shared\_\-ptr$<$ \bf{network::i\_\-socket} $>$ sock)
\begin{CompactList}\small\item\em remove\_\-music removes music-data from the \doxyref{music\_\-system}{p.}{classmusic_1_1music__system}. \item\end{CompactList}\item 
boost::shared\_\-ptr$<$ \bf{network::i\_\-socket} $>$ \bf{play\_\-music} (const string \&client, const string \&file)
\begin{CompactList}\small\item\em play\_\-music loggs the title and client from which you want to play music. Moreover it returns the socket from the music-client from which you want to play music. \item\end{CompactList}\item 
string \bf{suggest\_\-title} (const string \&client)
\begin{CompactList}\small\item\em suggest\_\-title suggests a title with the apriori algorithm. \item\end{CompactList}\item 
boost::shared\_\-ptr$<$ \bf{network::i\_\-socket} $>$ \bf{get\_\-socket} (const string \&client)
\begin{CompactList}\small\item\em get\_\-socket returns the socket from the apropriate music\_\-client \item\end{CompactList}\item 
boost::shared\_\-ptr$<$ \bf{model::dom} $>$ \bf{list\_\-clients} () const \label{classmusic_1_1music__system_f92a4e80730749c35a643f7f48a36d8e}

\begin{CompactList}\small\item\em list\_\-clients returns a dom-node of all available music clients with their music-data. \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
This class provides a facade for the whole music-system. 



Definition at line 44 of file music\_\-system.h.

\subsection{Member Function Documentation}
\index{music::music_system@{music::music\_\-system}!add_music@{add\_\-music}}
\index{add_music@{add\_\-music}!music::music_system@{music::music\_\-system}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void music::music\_\-system::add\_\-music (boost::shared\_\-ptr$<$ \bf{model::dom} $>$ {\em node}, boost::shared\_\-ptr$<$ \bf{network::i\_\-socket} $>$ {\em sock})}\label{classmusic_1_1music__system_2fb153710095c60e92d4b7a41e09b08c}


add\_\-music adds new music-data to the \doxyref{music\_\-system}{p.}{classmusic_1_1music__system}. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em node}]is the dom-node which stores all the new music-data \item[{\em sock}]is the socket from the client from which the data was received. \end{description}
\end{Desc}


Definition at line 8 of file music\_\-system.cpp.

\begin{Code}\begin{verbatim}10 {
11         boost::mutex::scoped_lock l(*_model->get_mutex());
12         _model->get_clients().push_back(model::client(*node));
13         _map[&_model->get_clients().back()] = sock;
14 }
\end{verbatim}\end{Code}


\index{music::music_system@{music::music\_\-system}!get_socket@{get\_\-socket}}
\index{get_socket@{get\_\-socket}!music::music_system@{music::music\_\-system}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}boost::shared\_\-ptr$<$ \bf{network::i\_\-socket} $>$ music::music\_\-system::get\_\-socket (const string \& {\em client})}\label{classmusic_1_1music__system_39c5fa768e7409605c5bb8fbf7d70b2d}


get\_\-socket returns the socket from the apropriate music\_\-client 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em client}]is the name of the music client\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]a shared\_\-ptr to the socket of the music client is returned. \end{Desc}


Definition at line 90 of file music\_\-system.cpp.

\begin{Code}\begin{verbatim}92 {
93         model::client *clt = _model->find_client(client);
94         if(clt == 0) {
95                 throw std::runtime_error("error, couldn't find client");
96         }
97         return _map[clt];
98 }
\end{verbatim}\end{Code}


\index{music::music_system@{music::music\_\-system}!play_music@{play\_\-music}}
\index{play_music@{play\_\-music}!music::music_system@{music::music\_\-system}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}boost::shared\_\-ptr$<$ \bf{network::i\_\-socket} $>$ music::music\_\-system::play\_\-music (const string \& {\em client}, const string \& {\em file})}\label{classmusic_1_1music__system_605b79919ed1f587b4fb04485509adda}


play\_\-music loggs the title and client from which you want to play music. Moreover it returns the socket from the music-client from which you want to play music. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em client}]is the name of the client. \item[{\em file}]is the filename of the title.\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]a shared\_\-ptr to the socket of the client is returned. \end{Desc}


Definition at line 49 of file music\_\-system.cpp.

\begin{Code}\begin{verbatim}52 {
53         boost::mutex::scoped_lock l(*_model->get_mutex());
54         model::client *clt = _model->find_client(client);
55         if(clt == 0) {
56                 throw std::runtime_error("error, couldn't find client");
57         }
58 
59         model::title *title = _model->find_title(file, clt);
60         if(title == 0) {
61                 throw std::runtime_error("error, couldn't find client");
62         }
63         boost::shared_ptr<model::title> t(title, core::null_deleter());
64 
65         file_streamer streamer(clt->get_name() + ".txt");
66         streamer.append_title(t);
67 
68         return _map[clt];
69 }
\end{verbatim}\end{Code}


\index{music::music_system@{music::music\_\-system}!remove_music@{remove\_\-music}}
\index{remove_music@{remove\_\-music}!music::music_system@{music::music\_\-system}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void music::music\_\-system::remove\_\-music (boost::shared\_\-ptr$<$ \bf{network::i\_\-socket} $>$ {\em sock})}\label{classmusic_1_1music__system_c211ac7dc2b3c8f5ecb00176a04e3e61}


remove\_\-music removes music-data from the \doxyref{music\_\-system}{p.}{classmusic_1_1music__system}. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em sock}]is the socket, which indicates the client, whichs data should be removed. \end{description}
\end{Desc}


Definition at line 16 of file music\_\-system.cpp.

\begin{Code}\begin{verbatim}18 {
19         boost::mutex::scoped_lock l(*_model->get_mutex());
20 
21         typedef map<model::client*, boost::shared_ptr<network::i_socket> >
22                 ::iterator it;
23         model::client *clt = 0;
24         it del;
25         for(it i = _map.begin(); i != _map.end(); ++i) {
26                 if(i->second == sock) {
27                         clt = i->first;
28                         del = i;
29                 }
30         }
31 
32         if(clt == 0) {
33                 throw std::runtime_error("error, couldn't find client");
34         }
35                 
36         typedef list<model::client>::iterator it2;
37         it2 i = _model->get_clients().begin();
38         it2 next = _model->get_clients().begin();
39         while(i != _model->get_clients().end()) {
40                 ++next;
41                 if(&(*i) == clt) {
42                         _model->get_clients().erase(i);
43                 }
44                 i = next;
45         }
46         _map.erase(del);
47 }
\end{verbatim}\end{Code}


\index{music::music_system@{music::music\_\-system}!suggest_title@{suggest\_\-title}}
\index{suggest_title@{suggest\_\-title}!music::music_system@{music::music\_\-system}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}string music::music\_\-system::suggest\_\-title (const string \& {\em client})}\label{classmusic_1_1music__system_ea6ba0059bdde315ff63778253f3adf5}


suggest\_\-title suggests a title with the apriori algorithm. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em client}]is the name of the music-client whose music should be played.\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]The filename of the suggested title is returned. \end{Desc}


Definition at line 71 of file music\_\-system.cpp.

\begin{Code}\begin{verbatim}72 {
73         boost::mutex::scoped_lock l(*_model->get_mutex());
74         model::client *clt = _model->find_client(client);
75         if(clt == 0) {
76                 throw std::runtime_error("error, couldn't find client");
77         }
78         boost::shared_ptr<model::client> clt_ptr(clt, core::null_deleter());
79 
80         boost::shared_ptr<music::data_miner> miner(new music::data_miner(
81                 clt_ptr, _model));
82         miner->doit();
83         boost::shared_ptr<model::title> t(miner->get_result());
84         if(t.get() == 0) {
85                 return "";
86         }
87         return t->get_filename();
88 }
\end{verbatim}\end{Code}




The documentation for this class was generated from the following files:\begin{CompactItemize}
\item 
music/music\_\-system.h\item 
music/music\_\-system.cpp\end{CompactItemize}
